package com.ruoyi.project.modules.fileInfo.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.modules.fileInfo.domain.FileInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.modules.fileInfo.mapper.FileInfoMapper;
import com.ruoyi.project.modules.fileInfo.service.IFileInfoService;
import com.ruoyi.common.core.text.Convert;

/**
 * 文件信息Service业务层处理
 *
 * @author smallrain
 * @date 2021-12-06
 */
@Service
public class FileInfoServiceImpl implements IFileInfoService {
    @Autowired
    private FileInfoMapper fileInfoMapper;

    /**
     * 查询文件信息
     *
     * @param id 文件信息主键
     * @return 文件信息
     */
    @Override
    public FileInf selectFileInfoById(Long id) {
        return fileInfoMapper.selectFileInfoById(id);
    }

    /**
     * 查询文件信息列表
     *
     * @param fileInf 文件信息
     * @return 文件信息
     */
    @Override
    public List<FileInf> selectFileInfoList(FileInf fileInf) {
        return fileInfoMapper.selectFileInfoList(fileInf);
    }

    /**
     * 新增文件信息
     *
     * @param fileInf 文件信息
     * @return 结果
     */
    @Override
    public int insertFileInfo(FileInf fileInf) {
        fileInf.setCreateTime(DateUtils.getNowDate());
        return fileInfoMapper.insertFileInfo(fileInf);
    }

    /**
     * 修改文件信息
     *
     * @param fileInf 文件信息
     * @return 结果
     */
    @Override
    public int updateFileInfo(FileInf fileInf) {
        fileInf.setUpdateTime(DateUtils.getNowDate());
        return fileInfoMapper.updateFileInfo(fileInf);
    }

    /**
     * 批量删除文件信息
     *
     * @param ids 需要删除的文件信息主键
     * @return 结果
     */
    @Override
    public int deleteFileInfoByIds(String ids) {
        return fileInfoMapper.deleteFileInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除文件信息信息
     *
     * @param id 文件信息主键
     * @return 结果
     */
    @Override
    public int deleteFileInfoById(Long id) {
        fileInfoMapper.deleteFileInfoByParentId(id);
        return fileInfoMapper.deleteFileInfoById(id);
    }

    @Override
    public List<FileInf> pageInterfaceImg(Long pageId, Long interfaceId) {
        return this.fileInfoMapper.pageInterfaceImg(pageId, interfaceId);
    }

    @Override
    public List<FileInf> queryPartImgByParentIdAndInterface(Long parentId, Long interfaceId) {
        return this.fileInfoMapper.queryPartImgByParentIdAndInterface(parentId, interfaceId);
    }

    @Override
    public List<FileInf> selectFileInfoList2(FileInf fileInf) {
        return this.fileInfoMapper.selectFileInfoList2(fileInf);
    }
}
